home *** CD-ROM | disk | FTP | other *** search
- program DemoR002;
- {------------------------------------------------------------------------------
- DBase Relational File Linkage
- Relational Examples
- Demo Program
-
- Copyright (c) Richard F. Griffin
-
- 10 February 1992
-
- 102 Molded Stone Pl
- Warner Robins, GA 31088
-
- -------------------------------------------------------------
- This unit demonstrates how to link the relationships between
- dBase files for data retrieval based on common fields in two files.
-
- The master file index is on the UNIQUEID field. This will be used
- to get the master record based on the MASTERID field in the
- transaction record.
-
- The routine will read each transaction and display transaction
- information. It will then find the correct master record and
- display master information.
-
- -------------------------------------------------------------------------------}
-
- uses
- CRT,
- GS_Date,
- GS_FileH,
- GS_KeyI,
- GS_Strng,
- GS_dBase,
- GS_dBFld;
-
- var
- MstrFile : GS_dBFld_Objt;
- TranFile : GS_dBFld_Objt;
- ftest : file;
-
- begin
- ClrScr;
-
- if not GS_FileExists(ftest, 'DEMOR1MF.DBF') then
- begin
- writeln('File DEMOR1MF.DBF not found. Run DEMOR001 to create.');
- halt;
- end;
-
- if not GS_FileExists(ftest, 'DEMOR1TF.DBF') then
- begin
- writeln('File DEMOR1TF.DBF not found. Run DEMOR001 to create.');
- halt;
- end;
-
- {The 'Real' example starts here}
-
- MstrFile.Init('DEMOR1MF');
- MstrFile.Open;
- MstrFile.Index('DEMOR1ID');
- TranFile.Init('DEMOR1TF');
- TranFile.Open;
- TranFile.GetRec(Top_Record);
- while not (TranFile.File_EOF) and (GS_KeyI_Chr <> #27) do
- begin
- ClrScr;
-
- {Display transaction information}
-
- Writeln('':34,'TRANSACTION');
- Writeln;
- Writeln(' FULLNAME : ',Strip_Flip(TranFile.StringGet('FULLNAME')));
- Writeln(' TRANDATE : ',GS_Date_View(TranFile.DateGet('TRANDATE')));
- Writeln(' AMOUNT : ',TranFile.FieldGet('AMOUNT'));
- Writeln(' PAYTYPE : ',TranFile.FieldGet('PAYTYPE'));
- Writeln;
- Writeln('':20,'-----------------------------------------');
- Writeln('':37,'MASTER');
- Writeln;
-
- {Now, go find the master record}
-
- if MstrFile.Find(TranFile.FieldGet('MASTERID')) then
- begin
- Writeln(' LASTNAME : ',MstrFile.FieldGet('LASTNAME'));
- Writeln(' FIRSTNAME : ',MstrFile.FieldGet('FIRSTNAME'));
- Writeln(' STREET : ',MstrFile.FieldGet('STREET'));
- Writeln(' ADDRESS : ',MstrFile.StringGet('CITY'),', ',
- MstrFile.FieldGet('STATE'),' ',
- MstrFile.FieldGet('ZIP'));
- end
- else writeln('Cannot Find the Master Record!');
-
- Writeln;
- Writeln('Press Any Key to Continue: ') ;
- Writeln('[ESC] Will Terminate the Program');
- WaitForKey;
- TranFile.GetRec(Next_Record);
- end;
- MstrFile.Close;
- TranFile.Close;
- end.